widget: Ensure all gestures outside a grab scope are cancelled
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 3 Jun 2014 13:04:25 +0000 (15:04 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 3 Jun 2014 14:13:25 +0000 (16:13 +0200)
This code is a product of early stages in the gestures branch, where
capturing would have an effect outside grab boundaries. But this isn't
really the case, so every gesture outside the grab scope must be reset
to avoid keeping stale data.

gtk/gtkwidget.c

index 8b90c3c83198c630fa4c3df18c83ca9d09f275e4..2aa5acc2e0950eed432bb2c5dbcf0f936ca06e63 100644 (file)
@@ -16887,40 +16887,15 @@ event_controller_grab_notify (GtkWidget           *widget,
                               gboolean             was_grabbed,
                               EventControllerData *data)
 {
-  GtkWidget *grab_widget, *toplevel;
-  GtkPropagationPhase phase;
-  GtkWindowGroup *group;
-  GdkDevice *device;
-
-  device = gtk_gesture_get_device (GTK_GESTURE (data->controller));
-  phase = gtk_event_controller_get_propagation_phase (data->controller);
-
-  if (!device)
-    return;
-
-  toplevel = gtk_widget_get_toplevel (widget);
-
-  if (GTK_IS_WINDOW (toplevel))
-    group = gtk_window_get_group (GTK_WINDOW (toplevel));
-  else
-    group = gtk_window_get_group (NULL);
+  GdkDevice *device = NULL;
 
-  grab_widget = gtk_window_group_get_current_device_grab (group, device);
-
-  if (!grab_widget)
-    grab_widget = gtk_window_group_get_current_grab (group);
+  if (GTK_IS_GESTURE (data->controller))
+    device = gtk_gesture_get_device (GTK_GESTURE (data->controller));
 
-  if (!grab_widget || grab_widget == widget)
+  if (!device || !gtk_widget_device_is_shadowed (widget, device))
     return;
 
-  if ((phase != GTK_PHASE_CAPTURE &&
-       !gtk_widget_is_ancestor (widget, grab_widget)) ||
-      (phase == GTK_PHASE_CAPTURE &&
-       !gtk_widget_is_ancestor (widget, grab_widget) &&
-       !gtk_widget_is_ancestor (grab_widget, widget)))
-    {
-      gtk_event_controller_reset (data->controller);
-    }
+  gtk_event_controller_reset (data->controller);
 }
 
 static void